// 编辑系列保存
// 系列编辑
function editsaveSeries() {
     // 获取值
     var seriesName = document.getElementById("seriesName").value
     var seriesID = document.getElementById("seriesId").value
     console.log("name" + seriesName + "abab" + seriesID)
     // 后台请求
    $.ajax({
        url: 'http://192.168.0.110:8080/CarManage/updateSeries',//请求后台的url
        method: 'post',//请求方式
        contentType: "application/x-www-form-urlencoded",
        data: {
            seriesName: seriesName,
            seriesID: seriesID
        },
        success: function (res) {
            console.log(res.msg)
            alert(res.msg)
        }
    })
    // 返回
    divset = document.getElementsByClassName("seriesSearch");
    for (var i = 0; i < divset.length; i++) {
        divset[i].style.display = "inline";
        location.reload();
    };
    divsetedit = document.getElementsByClassName("seriesEdit");
    for (var i = 0; i < divset.length; i++) {
        divsetedit[i].style.display = "none";
    };
    divsetadd = document.getElementsByClassName("seriesAdd");
    for (var i = 0; i < divset.length; i++) {
        divsetadd[i].style.display = "none";
    };
}
// 状态变化
// 品牌状态
function statusChange(validflag,seriesid) {
    // 获取当前状态
    console.log(validflag);
    // 判断当前状态更改
    if(validflag === 1){
       $('#modal-input').html('确认停用');
       $('#myModal').modal('show');
        var seriestatus=0
        console.log("dianji"+seriestatus+seriesid);
        changeStata(seriestatus,seriesid)
    }
    else{
       $('#modal-input').html('确认启用');
       $('#myModal').modal('show');
        var seriestatus=1
        console.log("dianji"+seriestatus+seriesid);
        changeStata(seriestatus,seriesid)
    }
}
// 品牌状态更改按钮
// 切换状态
function changeStata(seriestatus,seriesid) {
    $('#btn_ok').click(function(){
    $.ajax({
        url: 'http://192.168.0.110:8080/CarManage/updateSeriesStatus',
        method:'post',
        contentType:'application/x-www-form-urlencoded',
        data:{
            seriesID:seriesid,
            validFlag:seriestatus
        },
         success: function (res) {
            console.log(res.msg);
            $('#myModal').modal('hide');
            location.reload();
         }
    })
})
}
// 点击型号传id给型号页面
function seriesModel(xilieid,brandid) {
    console.log(xilieid)
     //跳转之前将局部页面保存到sessionStorage对象中。(键值名，值)
	window.sessionStorage.setItem("backId",brandid);
    // 传递参数
    window.location.href="model.html?"+"txt="+xilieid+brandid
}